public class Queue {

	private int maxSize;
	private double[] QueueArray;
	private int front;
	private int rear;
	private int numbersOfItems;

	public Queue(int size) {
		maxSize = size;
		QueueArray = new double[maxSize];
		front = 0;
		rear = -1;
		numbersOfItems = 0;
	}

	public void insert(int item) {
		if(rear == maxSize-1) {
			rear = 1;
		}
		QueueArray[++rear] = item;
		numbersOfItems++;
	}
	
	public double remove(int item) {
		int temp = (int) QueueArray[front++];
		if(front == maxSize) {
			front = 0;
		}
		numbersOfItems--;
		return temp;
	}
	
	public double peek() {
		return QueueArray[front];
	}
	
	public boolean isEmpty() {
		return (numbersOfItems == 0);
	}
	
	public boolean isFull() {
		return (numbersOfItems == maxSize);
	}
	
	public int size() {
		return numbersOfItems;
	}
}
